﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.DomainServices.Server;
using System.Web;

namespace Candy.Web.Data
{
    public class GeneDto
    {

        [Key]
        [Editable(false, AllowInitialValue = false)]
        public int Id { get; set; }

        [Editable(false, AllowInitialValue = true)]
        public int ProjectId { get; set; }

        [Required]
        public int FamilyId { get; set; }

        [Include]
        [Association("Family", "FamilyId", "Id")]
        public virtual FamilyDto Family { get; set; }


        public int? GenotypeId { get; set; }

        [Include]
        [Association("Genotype", "GenotypeId", "Id")]
        public virtual GenotypeDto Genotype { get; set; }

        [StringLength(10, MinimumLength = 3, ErrorMessage = "A gene name should be at least 3 characters long but not longer than 10 character.")]
        [RegularExpression(@"^[0-9A-Za-z]+[0-9A-Za-z/_]*[0-9A-Za-z]+$", ErrorMessage = "Name should only contain characters, numbers, / or _.")]
        [Required]
        public string Name { get; set; }

        [Required]
        [DefaultValue(true)]
        public bool AutogeneratedName { get; set; }

        [StringLength(50, MinimumLength = 3, ErrorMessage = "A identifier should be at least 3 characters long but not longer than 50 character.")]
        [RegularExpression(@"^[0-9A-Za-z]+[0-9A-Za-z_]*[0-9A-Za-z]+$", ErrorMessage = "Name should only contain characters, numbers or _.")]
        [Required]
        public string GeneIdentifier { get; set; }

        [Required]
        public GeneEntryType EntryType { get; set; }

        [Required]
        [DefaultValue(1)]
        public int ScientificRelevance { get; set; }

        [Editable(false)]
        public bool IsCandidate { get; set; }

        [RegularExpression(@"^[ARNDCEQGHILKMFPSTWYVUOBZJX]*$", ErrorMessage = "Invalid protein sequence.")]
        public string ProteinSequence { get; set; }


        [Required]
        [Editable(false, AllowInitialValue = true)]
        public DateTime CreateDate { get; set; }

        [Editable(false, AllowInitialValue = true)]
        public string CreatedBy { get; set; }

        
        [Association("Annotations", "Id", "GeneId")]
        public List<GeneAnnotationDto> Annotations { get; set; }


        public GeneDto()
        {
            // g.i
        }
    }
}